<?php
session_start(); 
// set timeout period in seconds
$inactive = 600;
// check to see if $_SESSION['timeout'] is set
if (isset($_SESSION['timeout']) ) 
{
$session_life = time() - $_SESSION['timeout'];
	if ($session_life > $inactive)
	{
	session_destroy();
	$_SESSION['message'] = 'You have been logged out due to inactivity'; 
	header("Location: login.php"); 
	}
	else 
	{$_SESSION['timeout'] = time();}
}
?>